﻿<%@ Page Language="C#" Inherits="WebSys.UI.Login" %>

<%@ Register Assembly="WebSys.UI" Namespace="WebSys.UI.Control.ZhengShou" TagPrefix="CBW" %>
<%@ Register Assembly="Antu.WebControls" Namespace="Antu.WebControls" TagPrefix="CBW" %>
<%--<CBW:MPContainer runat="server" ID="MPContainer" IsRoot="false" ThemeMasterFile="Master.ascx">
    <CBW:MPContent id="MainerRegion" runat="server">
        <CBW:LoginControl ID="LoginControl" runat="server" />
    </CBW:MPContent>
</CBW:MPContainer>--%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>江宁区国有土地上征收管理系统登录</title>
    <style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	overflow:hidden;
}
.STYLE3 {font-size: 12px; color: #adc9d9; }
-->
</style>

    <script type="text/javascript" >
        document.write("<object CLASSID='clsid:e6bd6993-164f-4277-ae97-5eb4bab56443' ID='ET99' NAME='ET99' CODEBASE='../files/et99.cab#Version=1,00,0000' BORDER='0' VSPACE='0' HSPACE='0' ALIGN='TOP' HEIGHT='0' WIDTH='0'> </object>");
    </script>

    <script src="../Script/jquery-1.7.1.js" type="text/javascript"></script>

    <script type="text/javascript" >
        var pid = "B178B1B1";
        var check = null;
        var isexist = false;
        var md5username = "";

        //检查客户端是否已安装了组件
        function ExistET99ActiveX() {
            try {
                var obj = new ActiveXObject("ET99_FULL.ET99Full.1");
            } catch (e) {
                return false;
            }
            return true;
        }
        //检查是否插入Key
        function StartCheck() {

            var result = check.ET_Monitor();
            switch (result) {
                case 0:
                    isexist = false;
                   // alert("请插入UsbKey");
                    break;
                case 1: //插入
                case 3:
                    if (isexist == false) {
                        isexist = true;
                        Init();
                    }
                 //   alert("已插入UsbKey，请输入登录密码！");
                    break;
                case 2: //移除  
                    isexist = false;
                   // document.getElementById('<%= UserName.ClientID %>').value = "";
                   // alert("已拨出UsbKey");
                    break;
            }
            setTimeout('StartCheck()', 2000);
        }

        //初始化
        function Init() {
            if (ExistET99ActiveX()) {
                var eobj = new ActiveXObject("ET99_FULL.ET99Full.1");
                var count = 0;
                try {
                    count = eobj.FindToken(pid);
                } catch (e) {
                 // alert("未找到UsbKey设备!");
                }

                try {
                    if (count == 1) {
                        eobj.OpenToken(pid, 1);
                        var sn = eobj.GetSN();
                        //  $("#showsn").html(sn);
                        $.get("getajax.aspx?act=login&sn=" + sn + "&rd=" + Math.random(), function(res) {
                            var arrayres = res.split('|');

                            var username = document.getElementById('<%= UserName.ClientID %>');
                            document.getElementById('<%= UserName.ClientID %>').setAttribute("onfocus", "this.blur()");
                            username.value = arrayres[0];
                            md5username = arrayres[1];
                        });
                    } else {
                       // alert("UsbKey存在" + count + "个，只允许一个UsbKey存在!");
                    }

                } catch (e) {
                    //alert("UsbKey初始化失败!");
                }
            } else {
                //alert("请下载驱动安装!");
            }
        }

        function CheckLoginOn() {
            var username = document.getElementById('<%= UserName.ClientID %>');
        if (username.value == "") {
            //alert("用户名不得为空!");
            return false;
        }
        var eobj = new ActiveXObject("ET99_FULL.ET99Full.1");

        eobj.OpenToken(pid, 1);
        eobj.VerifyPIN(0, md5username);

       
          var rd = '<%= HttpContext.Current.Session["radom"] %>';
          var digest = eobj.MD5HMAC(1, rd, rd.length);
          document.getElementById("clientstr").value = digest;
          return true;
            
        }

        $(document).ready(function () {
            check = new ActiveXObject("CheckUSBCom.ETCheckUSB.1"); 
            StartCheck();

        });
    </script>
    
</head>
<body>
    <form id="form1" runat="server">
        <table  width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td bgcolor="#1075b1">
                    &nbsp;</td>
            </tr>
            <tr>
                <td height="608" background="<%= Antu.Core.Components.SiteSettings.DefaultSiteSettings.DefaultThemeFolderMapPath %>Images/login_03.gif">
                    <table width="847" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                            <td height="318" background="<%= Antu.Core.Components.SiteSettings.DefaultSiteSettings.DefaultThemeFolderMapPath %>Images/login_04.jpg">
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td height="84">
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td width="381" height="84" background="<%= Antu.Core.Components.SiteSettings.DefaultSiteSettings.DefaultThemeFolderMapPath %>Images/login_06.gif">
                                            &nbsp;</td>
                                        <td width="162" valign="middle" background="<%= Antu.Core.Components.SiteSettings.DefaultSiteSettings.DefaultThemeFolderMapPath %>Images/login_07.gif">
                                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td width="44" height="24" valign="bottom">
                                                     <input id="clientstr" name="clientstr" type="text" style="display: none" />
                                                        <div align="right">
                                                            <span class="STYLE3">用户</span></div>
                                                    </td>
                                                    <td width="10" valign="bottom">
                                                        &nbsp;</td>
                                                    <td height="24" colspan="2" valign="bottom">
                                                        <div align="left">
                                                            <asp:TextBox ID="UserName" runat="server" Style="width: 80px; height: 17px; background-color: #87adbf;
                                                                border: solid 1px #153966; font-size: 12px; color: #283439;"></asp:TextBox>
                                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="*"
                                                                ControlToValidate="UserName"></asp:RequiredFieldValidator>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td height="24" valign="bottom">
                                                        <div align="right">
                                                            <span class="STYLE3">密码</span></div>
                                                    </td>
                                                    <td width="10" valign="bottom">
                                                        &nbsp;</td>
                                                    <td height="24" colspan="2" valign="bottom">
                                                        <asp:TextBox ID="Password" runat="server" TextMode="Password" Style="width: 80px;
                                                            height: 17px; background-color: #87adbf; border: solid 1px #153966; font-size: 12px;
                                                            color: #283439;"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="*"
                                                            ControlToValidate="Password"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                </tr>
                                            </table>
                                        </td>
                                        <td width="26">
                                            <img src="<%= Antu.Core.Components.SiteSettings.DefaultSiteSettings.DefaultThemeFolderMapPath %>Images/login_08.gif" width="26" height="84"></td>
                                        <td width="67" background="<%= Antu.Core.Components.SiteSettings.DefaultSiteSettings.DefaultThemeFolderMapPath %>Images/login_09.gif">
                                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td height="25">
                                                        <div align="center">
                                                            <asp:ImageButton Width="57" Height="20"  ID="login" runat="server"
                                                                Text="登录" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td height="25">
                                                        <div align="center">
                                                            <img src="<%= Antu.Core.Components.SiteSettings.DefaultSiteSettings.DefaultThemeFolderMapPath %>Images/cz.gif" width="57" height="20" style="cursor: pointer" onclick='form1.reset();'></div>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td width="211" background="<%= Antu.Core.Components.SiteSettings.DefaultSiteSettings.DefaultThemeFolderMapPath %>Images/login_10.gif">
                                            </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td height="206" background="<%= Antu.Core.Components.SiteSettings.DefaultSiteSettings.DefaultThemeFolderMapPath %>Images/login_11.gif">
                                &nbsp;</td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td bgcolor="#152753">
                    &nbsp;<div id="showmsg"></div></td>
            </tr>
        </table>
    </form>
</body>
</html>
